How do I put these: @{$subset}, [@ext_subset], [$last_item] in PHP?

Posted by Alex on Stack Overflow See other posts from Stack Overflow or by Alex
Published on 2010-03-11T22:22:38Z Indexed on 2010/03/12 7:27 UTC
Read the original article Hit count: 126

Filed under:
|

I'm having trouble translating a subroutine from Perl to PHP (I'm new to Perl). The entire subroutine is as follows:

sub find_all_subsets {
  if (1 == scalar (@_)) {return [@_]}
  else {
    my @all_subsets = () ;
    my $last_item = pop (@_) ;
    my @first_subsets = find_all_subsets (@_) ;
    foreach my $subset (@first_subsets) {
      push (@all_subsets, $subset) ;
      my @ext_subset = @{$subset} ;
      push (@ext_subset, $last_item) ;
      push (@all_subsets, [@ext_subset]) ;
    }
    push (@all_subsets, [$last_item]) ;
    return (@all_subsets) ;
  }
}

My problem is that I really don't quite understand the Perl syntax, so I'm having trouble writing these @{$subset}, [@ext_subset] and [$last_item] in PHP.

Thanks and sorry if the question is stupid.

© Stack Overflow or respective owner

Related posts about perl

Related posts about php